@extends('layout/default')

@section('content')

    <div class="container ">
        <div clas="row ">
            <form action="{{url('/register')}}" METHOD="post">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <input type="hidden" name="CWebChatID" value="{{Session::get('CWebChatID')}}">
                <input type="hidden" name="nickname" value="{{Session::get('CName')}}">

                <div class=" col-xs-12 box-content">
                    <div class="row ">
                        <div class="col-xs-12"><label>微信用户：{{Session::get('CName')}}</label></div>

                    </div>
                    <div class="row ">
                        <label class=" form-label" for="mobile">手机：</label>

                        <div class="col-xs-12"><input class="form-input " id="mobile" name="CMobile"
                                                      value="{{Input::get('CMobile')}}" required
                                                      pattern="^1[3|4|5|8][0-9]\d{4,8}$" placeholder="11位手机号"
                                                      maxlength="11"></div>

                    </div>
                    <div class="row ">
                        <label class=" form-label" for="mobile">密码：</label>

                        <div class="col-xs-12"><input class=" form-input" id="pwd" name="CPwd" type="password"
                                                      value="{{Input::get('CPwd')}}" required parent="^[A-Za-z0-9]{7}$"
                                                      placeholder="6-20位数字或字符"></div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6 ">
                            <input class="col-xs-12" type="number" pattern="^.{4}$" style="padding: 0.3em" name="cnum"
                                   value="{{Input::get('cnum')}}" placeholder="数字验证码" required>
                        </div>
                        <div class="col-xs-6">
                            <input class="col-xs-12 btn btn-primary" type="button" value="获取验证码" id="get-code">
                        </div>

                    </div>
                    <div class="row ">
                        <label class=" form-label" for="mobile">姓名：</label>

                        <div class="col-xs-12"><input class=" form-input" id="mobile" name="CName"
                                                      value="{{Session::get('CName')}}" maxlength="20" required
                                                      placeholder="最多20个字符"></div>
                    </div>

                    <div class="row">
                        <div class="col-xs-6">
                            <input type="radio" name="CSex" checked="check" id="sex_m" value="0"><label for="">&nbsp;&nbsp;男</label>
                        </div>

                        <div class="col-xs-6">
                            <input type="radio" name="CSex" id="sex_f"
                                   value="1" {{Input::get('CSex')==1?'checked="true"':''}}><label for="sex_f">&nbsp;&nbsp;女</label>
                        </div>
                    </div>


                </div>
                <input class="col-xs-12 box-footer btn btn-primary" value="注册" type="submit">
                已有账号?立即<a href="{{url('binding')}}">绑定</a>


            </form>
        </div>

    </div>
@endsection
@section('scripts')
    <script>
        $(function () {
            $('#get-code').click(function () {

                $.ajax({
                    url: "{{url('/code')}}",
                    type: 'GET',
                    data: {
                        _token: "{{csrf_token()}}",
                        ctype: 1,
                        CMobile: $('input[name="CMobile"]').val()
                    },
                    success: function (data) {

                        $('#get-code').attr('disabled', true)
                        var i = 60;
                        var interval = setInterval(function () {
                            i--;
                            if (i == 0) {
                                $('#get-code').attr('disabled', false).val('获取验证码');

                                clearInterval(interval)
                            } else {

                                $('#get-code').val(i + '秒后重新获取');
                            }

                        }, 1000)
                        //测试
                        if (data) {
                            $('input[name="cnum"]').val(data)
                        }
                    }
                })

            })
            //字段验证


        })

    </script>
@endsection